<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:58:"D:\phpStudy\WWW\auth/application/web\view\show\ptview.html";i:1496201810;}*/ ?>
 
<link rel="shortcut icon" href="favicon.ico">
<link href="__CSS__/bootstrap.min.css" rel="stylesheet">
<link href="__CSS__/font-awesome.min.css" rel="stylesheet">
<link href="__CSS__/animate.min.css" rel="stylesheet">
<link href="__CSS__/style.min.css" rel="stylesheet">
<link href="__CSS__/admin.css" rel="stylesheet">
<div class="ibox float-e-margins">
	<div class="ibox-content form-horizontal">
		<!--商品栏目设置-->
		<div class="form-group">
			<label class="col-sm-3 control-label">店铺当前积分余额：</label>
			<div class="input-group col-sm-4">
				<label class="col-sm-3 control-label" style="margin-left: -10px;text-align: left;"><?php echo $score; ?></label>
				<button class="btn cz"><i class="fa fa-save"></i> 充值</button>
			</div>
		</div>
		<!--<div class="form-group">
			<label class="col-sm-3 control-label">云拼团栏目商品名称：</label>
			<div class="input-group col-sm-4">
				<input type="text" id="pt_name" name="pt_name" value="<?php echo $ptgood['pt_name']; ?>" class="form-control" />
			</div>
		</div>-->
		<div class="form-group">
			<label class="col-sm-3 control-label">参团人数：</label>
			<div class="input-group col-sm-4">
				<input type="text" id="ptneed_person" name="ptneed_person" value="<?php echo $ptgood['ptneed_person']; ?>" class="form-control" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">结束时间：</label>
			<div class="input-group col-sm-4">
				<input id='pt_endtime' value="<?php echo $ptgood['pt_endtime']; ?>" name='pt_endtime' onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:00'})"  style="width: 190px;"  type='text' placeholder="结束时间" class="form-control layer-date" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">购买商品该需要现金：</label>
			<div class="input-group col-sm-4">
				<input style="width: 40%;" type="text" id="ptneed_money" name="ptneed_money" value="<?php echo $ptgood['ptneed_money']; ?>" class="form-control" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'') "/>
				<lable style="width: 25%;    padding-right: 0px; padding-left: 0px;font-weight: bold;" class="col-sm-3 control-label">&nbsp;送积分：</lable>
				<input style="width: 35%;" type="text" id="ptgive_score" name="ptgive_score" value="<?php echo $ptgood['sale_price']; ?>" readonly="readonly" class="form-control" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'') "/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">上架数量：</label>
			<div class="input-group col-sm-4">
				<input type="text" id="pt_num" name="pt_num" value="<?php echo $ptgood['pt_num']; ?>" class="form-control" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'') "/>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">状态：</label>
			<div class="input-group col-sm-4" id="pt_status">
			<input type="radio" name="is_pt" id="is_pt" value="0" <?php if($ptgood['is_pt']==0): ?> {php echo checked="true"} <?php endif; ?>/> 关闭
			&nbsp;
			<input type="radio" name="is_pt" id="is_pt" value="1" <?php if($ptgood['is_pt']==1): ?> {php echo checked="true"} <?php endif; ?>/> 开启
			</div>
		</div>
		<!--商品栏目设置end-->
		
		
		<div class="form-group">
			<div class="col-sm-4 col-sm-offset-8" style="text-align: right;">
				<button class="btn btn-info"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;
				<span onclick="wclose()"><a class="btn btn-danger"><i class="fa fa-arrow-left"></i> 返回 </a></span>
			</div>
		</div>
	</div>
</div>
 
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/bootstrap.min.js"></script>
<script src="__JS__/jquery.metisMenu.js"></script>
<script src="__JS__/jquery.slimscroll.min.js"></script>
<script src="__LIB__/layer/layer.js"></script>
<script src="__LIB__/datepicker/WdatePicker.js"></script>
<script>
	function wclose(){
    	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
        parent.layer.close(index);  
	}
	$(".cz").click(function(){
		parent.layer.closeAll();
		parent.window.location.href="../agent/exchange.html?type=1";//<?php echo url('',array('type'=>1)); ?>
		//location.href="../agent/recharge.html";
	});
	$(".btn-info").click(function(){
		var dt=new Date();
    	var id = '<?php echo $id; ?>';
    	var score = '<?php echo $score; ?>';
    	var ptgive_score = $("#ptgive_score").val();
    	var pt_num = $("#pt_num").val();
    	var ptneed_person = $("#ptneed_person").val();
    	var pt_endtime=$("#pt_endtime").val();
    	if(ptgive_score*pt_num*ptneed_person>score){	    	
    		layer.msg("积分不足");
    		return;
    	}
    	var pt_name = $("#pt_name").val();
    	/*if(!pt_name){	    	
    		layer.msg("请输入商品名称");
    		return;
    	}  */	
    	if(!ptneed_person||ptneed_person==0){	    	
    		layer.msg("请输入参团人数");
    		return;
    	}
    	if(pt_endtime==""){	    	
    		layer.msg("请选择团结束日期");
    		return;
    	}
    	if(dt>=new Date(pt_endtime)){
    		layer.msg("团结束时间必须大于当前时间");
    		return;
    	}
    	if(!pt_num||pt_num==0){	    	
    		layer.msg("请输入上架数量");
    		return;
    	}
    	
		
    	$.ajax({
            type:"POST",
            url:"savept",
			data:{pt_endtime:pt_endtime,id:id,pt_name:$("#pt_name").val(),ptneed_person:$("#ptneed_person").val(),ptneed_money:$("#ptneed_money").val(),ptgive_score:$("#ptgive_score").val(),is_pt:$('#pt_status input[name="is_pt"]:checked').val(),pt_num:$("#pt_num").val()},
            success:function(data){
				layer.msg(data.msg, {
				  icon: 1,
				  time: 1000 //2秒关闭（如果不配置，默认是3秒）
				}, function(){
					if(data.code == 200) {
						parent.layer.closeAll();
   						parent.window.location.reload();
   					}
				}); 
            }
		});		
    });
    $("#ptneed_money").keyup(
    	function(){
    		var money=$('#ptneed_money').val();
    		var score=money;
    		$("#ptgive_score").val(score);
    	}
    );
</script>
